<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/11
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-content">

                    <div class="jqGrid_wrapper">
                        <div class="ui-jqgrid " id="gbox_table_list_2" dir="ltr">
                            <div class="ui-jqgrid-view table-responsive" role="grid" id="gview_table_list_2"
                            >


                                <form role="form" class="form-inline" style="margin-bottom: 10px" id="searchForm"
                                      method="post" action="checkDemandList.html">
                                    <input type="hidden" id="pageName" name="pageName" value="${pageName}">
                                    <input type="hidden" id="status" name="status" value="12">
                                    <input type="hidden" id="isFinish" name="status" value="${isFinish}">
                                    <div class="form-group">


                                        <input type="text" name="conditions['createName']" placeholder="录入人"
                                               value="${pages.conditions.createName}"
                                               id="createName" class="form-control">&nbsp;&nbsp;&nbsp;
                                        <select id="demandProduct" name="conditions['demandProduct']"
                                                class="form-control"
                                                required="" aria-required="true">
                                            <option value="0"
                                                    <c:if test="${pages.conditions.demandProduct == 0}">selected</c:if>>
                                                问题产品
                                            </option>
                                            <c:forEach items="${productList}" var="product">
                                                <option
                                                        <c:if test="${pages.conditions.demandProduct == product.id}">selected</c:if>
                                                        value="${product.id}">${product.product_name}</option>
                                            </c:forEach>
                                        </select>
                                        &nbsp;&nbsp;
                                        <input name="conditions['feedbackName']" id="feedbackName"
                                               placeholder="反馈人"
                                               type="text" size="8" value="${pages.conditions.feedbackName}"
                                               class="form-control">&nbsp;&nbsp;
                                        <input name="conditions['demId']" id="demId"
                                               placeholder="编号"
                                               type="text" size="8" value="${pages.conditions.demId}"
                                               class="form-control">&nbsp;&nbsp;
                                        &nbsp;&nbsp;

                                    </div>
                                    &nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary">搜索</button>
                                    &nbsp;&nbsp;&nbsp;<button type="button" id="resetBut" class="btn btn-reset">重置
                                </button>
                                </form>


                                <div class="ui-jqgrid-bdiv">
                                    <div style="position:relative;">
                                        <div></div>
                                        <table id="cusTable"
                                               class="ui-jqgrid-btable ui-common-table table table-bordered"
                                        >
                                            <tbody>
                                            <tr role="row" style="background: #F5F5F5;">
                                                <!--<td><input th:type="checkbox" name="ches"/>-->
                                                <td>编号
                                                </td>
                                                <td>标题
                                                </td>
                                                <td>描述</td>
                                                <td>反馈人
                                                </td>
                                                <td>所属产品

                                                </td>
                                                <td>录入人
                                                </td>
                                                <td style="width: 15%">录入时间
                                                </td>


                                                <td>操作
                                                </td>
                                            </tr>


                                            <c:forEach items="${pages.pageDatas}" var="demand">
                                                <tr role="row" id="1" tabindex="-1"
                                                    class="jqgrow ui-row-ltr" demandId="${demand.id}"
                                                    statusText="${demand.status_text}">
                                                    <td>${demand.id}
                                                    </td>
                                                    <td>${demand.title}
                                                    </td>
                                                    <td>
                                                            ${fn:length(demand.detail) > 20 ? fn:substring(demand.detail,0,20) : demand.detail}

                                                    </td>
                                                    <td>
                                                            ${demand.feedback_name}
                                                    </td>
                                                    <td>
                                                            ${demand.demand_product_name}
                                                    </td>
                                                    <td>
                                                            ${demand.create_name}
                                                    </td>
                                                    <td>
                                                            ${demand.create_time}
                                                    </td>



                                                    <td>

                                                            <a id="chbtn" demId="${demand.id}"
                                                               title="评价"
                                                               class="handleicon" type="button"><i
                                                                    class="fa fa-pencil-square-o"></i>
                                                            </a>

                                                        <a id="fnibtn" demId="${demand.id}"
                                                           title="完成"
                                                           class="handleicon" type="button"><i
                                                                class="fa fa-check-circle"></i>
                                                        </a>

                                                    </td>
                                                </tr>

                                            </c:forEach>


                                            </tbody>
                                        </table>
                                        <c:if test="${pages.totalPages>1 }">
                                            <page:pager pageSize="${pages.pageSize}" currPage="${pages.currPage}"
                                                        totalRecords="${pages.totalRecords}"
                                                        url="${pageContext.request.contextPath}/checkDemandList.html?conditions['demandProduct']=${pages.conditions.demandProduct }&conditions['createName']=${pages.conditions.createName }&conditions['demId']=${pages.conditions.demId }&&conditions['feedbackName']=${pages.conditions.feedbackName }&pageName=${pageName }&status=12&isFinish=${isFinish}"/>

                                        </c:if>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--弹框用-->

</body>

<script>

    $(function () {
        $("#resetBut").click(function () {
            $('#createName').val("");
            $('#demandProduct').val("0");
            $('#demId').val("");
            $('#feedbackName').val("");
        })
    })

    var param = "";
    $(function () {

        $("[id=chbtn]").click(function () {

            var title = "客户评价";

            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['30%', '65%'], //宽高
                content: 'goCustFeedback.html?&demId=' + $(this).attr('demId')
//                end: function () {
//                    location.reload();
//                }
            });
        });



        $("[id=fnibtn]").click(function () {
            var demandId = $(this).attr('demId');

            var title = "确定完成？";

            var obj = $(this);
            layer.msg(title, {
                time: 0 //不自动关闭
                , btn: ['确定', '取消']
                , yes: function (index) {


                    var args = {
                        "id": demandId
                    }

                    var url = "finishDemand.html";

                    //加载进度条
                    layer.load(2, {
                        shade: [0.2, '#999999'] //0.1透明度的白色背景
                    });
                    $.post(url, args, function (data) {
                        data = jQuery.parseJSON(data);
                        //保存成功
                        if (data.code == 1) {
                            window.location.reload();
                            layer.closeAll('loading');
                        } else {
                            //失败
                            layer.alert(data.msg);
                            layer.closeAll('loading');
                        }
                    });
                    layer.close(index);

                }
            });
        });




        var index = 0;


        //双击tr弹出页面
        $("#cusTable tr td").dblclick(function () {

            //alert($(this).html());
            //alert($(this).attr('custId'));
            //alert($(this).parent('tr').attr('custId'));
            var title = "需求-" + $(this).parent('tr').attr('statusText');
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['90%', '90%'], //宽高
                content: 'demandDetail.html?isCheck=true&demandId=' + $(this).parent('tr').attr('demandId'),
                end: function () {
                    location.reload();
                }
            });
        });
    });

</script>
</html>
